<template>
  <div id="news">
    <div class="one" v-for="(book,id) in books" :key="id">
      <div class="zuo">
        <div class="topleft">
          <div>{{book.wenben}}</div>
        </div>
        <div class="bottom">
          <span class="guojia">{{ book.username1 }}</span>
          <span class="shijian">{{ book.username2 }}</span>
        </div>
      </div>
      <div class="you">
        <img v-bind:src="book.img" alt="" />
      </div>
    </div>
  </div>
</template>

<script>
// import axios from "axios";
export default {
  name: "App",
  components: {},
  data() {
    return {
    books: [],
    };
  },
  created() {
    let xhr = new XMLHttpRequest();
    xhr.open("get", "http://localhost:3000/fanzhazhongxin");
    xhr.onreadystatechange = () => {
      if (xhr.readyState == 4 && xhr.status == 200) {
        console.log("xhr.responseText", xhr.responseText);
        this.books = JSON.parse(xhr.responseText);
      }
    };
    xhr.send();
  },
};
</script>

<style>
#news {
  width: 100%;
  min-height: 70rem;
  background-color: #e6ecea;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.one {
  height: 7rem;
  width: 100%;
  /* background-color: cadetblue; */
  display: flex;
  justify-content: space-between;
}
.zuo {
  width: 60%;
  height: 7rem;
  /* background-color: chocolate; */
  display: flex;
  flex-direction: column;
}
.topleft {
  font-size: 0.22rem;
  height: 80%;
}
.bottom {
  height: 20%;
  display: flex;
  justify-content: space-between;
}
.guojia {
  font-size: 0.14rem;
  color: darkgrey;
  width: 60%;
}
.shijian{
  width: 39%;
  font-size: 0.14rem;
  color: darkgrey;

}
.you {
  width: 39%;
  height: 1.4rem;
}
.you img {
  width: 100%;
  height: 7rem;
}
.two {
  height: 1.4rem;
  width: 100%;
}
.three {
  height: 1.4rem;
  width: 100%;
}
.four {
  height: 1.4rem;
  width: 100%;
}
.five {
  height: 1.4rem;
  width: 100%;
}
</style>
